#include <iostream>
#include <string>
using namespace std;
int main()
{
	int a=10;
	int b=9801;
	int T;
	cin >> T;
	string s="";
	while(T--)
	{
		int n;
		cin >> n;
		for(int i=0;i<=200;i++)
		{
			int c=a/b;
			int d=a%b;
			s.push_back(c+'0');
			a=d*10;
		}
		cout << s[n-1] << endl;
	}
	return 0;
}
